#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
    bool row[9][10];
    bool col[9][10];
    bool grid[3][3][10];
public:
    bool isValidSudoku(vector<vector<char>>& board)
    {
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                if (board[i][j] != '.')
                {
                    int nums = board[i][j] - '0';
                    if (row[i][nums] || col[j][nums] || grid[i / 3][j / 3][nums])
                        return false;
                    row[i][nums] = col[j][nums] = grid[i / 3][j / 3][nums] = true;
                }
            }
        }
        return true;
    }
};